package com.open.rbac.service.id.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.open.rbac.model.entity.id.Identity;

@Transactional(rollbackFor = Exception.class)
public interface IdentityRepository extends JpaRepository<Identity, String>, JpaSpecificationExecutor<Identity> {

    List<Identity> findByIdMd5(String md5);

    @Modifying
    @Query("UPDATE identity t1 SET t1.isDeleted = true WHERE t1.id IN (?1)")
    void deleteByIds(List<String> ids);

}
